package com.atguigu.gmall.activity.controller;

import com.atguigu.gmall.activity.entity.UserRecode;
import com.atguigu.gmall.activity.service.SeckillService;
import com.atguigu.gmall.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月16日 18:16
 * @ClassName:SeckillOrderController
 * @Description: TODO
 */
@RestController
@RequestMapping("/seckill/order")
public class SeckillOrderController {

    @Autowired
    private SeckillService seckillService;

    /**
     * 秒杀下单
     * @param skuId
     * @param time
     * @return
     */
    @GetMapping("/add")
    public Result addSeckillOrder(String skuId,String time){
       String username = "changanyu";
        UserRecode userRecode = seckillService.addOrder(time, skuId, username);
        return  Result.ok(userRecode);
    }
    /**
     * 查询用户的排队信息
     * @return
     */
    @GetMapping("/getRecode")
    public  Result getUserRecode(){
        String username = "changanyu";
        UserRecode userRecode = seckillService.getUserRecode(username);
        return Result.ok(userRecode);
    }
    /**
     *查询秒杀订单的信息
     * @param orderId
     * @return
     */
    @GetMapping("/getSeckillOrder")
    public Result getSeckillOrder(String orderId){
        String username = "changanyu";
       return Result.ok( seckillService.getSeckillOrderList(username,orderId));
    }
}
